package pers.course.week11;

import java.util.Scanner;

public class LetterA {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        Line[] line = new Line[3];
        for (int i = 0; i < num; i++) {
            for (int j = 0; j < 3; j++) {
                double ax, ay, bx, by;
                ax = scan.nextDouble();
                ay = scan.nextDouble();
                bx = scan.nextDouble();
                by = scan.nextDouble();
                Point a = new Point(ax, ay);
                Point b = new Point(bx, by);
                line[j] = new Line(a, b);
            }
            int i1 = 0, j1 = 0;
            boolean flag = false;
            for (; i1 < 2; i1++) {
                for (j1 = i1 + 1; j1 < 3; j1++) {
                    if (line[i1].hasSamePoint(line[j1])) {
                        flag = true;
                        break;
                    }
                }
                if (flag) break;
            }
            int middle = 0;   //表示中间的横在line中的index
            for (int n = 0; n < 3; n++) {
                if (n != i1 && n != j1) {
                    middle = n;
                    break;
                }
            }
            if (flag && line[i1].PointOnLine(line[middle].A) && line[j1].PointOnLine(line[middle].B)) {
                if (line[i1].ifRight(line[middle].A) && line[j1].ifRight(line[middle].B))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            } else if (flag && line[i1].PointOnLine(line[middle].B) && line[j1].PointOnLine(line[middle].A)) {
                if (line[i1].ifRight(line[middle].B) && line[j1].ifRight(line[middle].A))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            } else {
                System.out.println("NO");
            }
        }
        scan.close();
    }
}

class Point {
    private double x, y;           //a表示横坐标，b表示纵坐标

    Point(double x, double y) {
        this.x = x;
        this.y = y;
    }

    public double Getx() {
        return x;
    }

    public double Gety() {
        return y;
    }

    public double Distance(Point a) {
        return Math.sqrt((a.x - this.x) * (a.x - this.x) + (a.y - this.y) * (a.y - this.y));
    }

    public boolean equal(Point a) {
        if (this.Getx() == a.Getx() && this.Gety() == a.Gety())
            return true;
        return false;
    }
}

class Line {
    Point A, B;

    Line(Point A, Point B) {
        if (A == B) {
            System.out.println("无法构成线段！！！");
        } else {
            this.A = A;
            this.B = B;
        }
    }

    public boolean hasSamePoint(Line a) {
        if (A.equal(a.A) || A.equal(a.B) || B.equal(a.A) || B.equal(a.B)) {
            return true;
        } else
            return false;
    }

    public boolean PointOnLine(Point a) {
        double maxx = Math.max(A.Getx(), B.Getx());
        double minx = Math.min(A.Getx(), B.Getx());
        double maxy = Math.max(A.Gety(), B.Gety());
        double miny = Math.min(A.Gety(), B.Gety());
        if (a.Getx() > maxx || a.Getx() < minx || a.Gety() > maxy || a.Gety() < miny) {
            return false;
        }
        if (A.Getx() == B.Getx()) {
            if (a.Getx() == A.Getx())
                return true;
        } else {
            double k = (A.Gety() - B.Gety()) / (A.Getx() - B.Getx());
            if (a.Gety() - A.Gety() == k * (a.Getx() - A.Getx()))
                return true;
        }
        return false;
    }

    public boolean ifRight(Point a) {
        double max = Math.max(A.Distance(a), B.Distance(a));
        double min = Math.min(A.Distance(a), B.Distance(a));
        if (min / max >= 0.25)
            return true;
        return false;
    }
}